package Messages;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import ocsf.server.ConnectionToClient;
import server.SQLConnection;

/**
 * This class get Private customers info from the DB 
 * @author Gabi Revah
 * @author Aviad Almogr
 *
 */
public class MessagePullPrivate {

	private ConnectionToClient client ;
	private String[] str; 
	
/**
 * * Contractor of this class 	
 * @param str
 * @param client
 */
	public MessagePullPrivate(String[] str, ConnectionToClient client) {
		this.client= client ;
		this.str= str; 	
	}
/**
 *  This method pull Private customers from the DB 	
 * @throws SQLException
 * @throws IOException
 */
	public void PullPrivate() throws SQLException, IOException{
		SQLConnection sc = new SQLConnection();
		java.sql.PreparedStatement pulpri = sc.getConnection().prepareStatement("SELECT * FROM db.private;");
		ResultSet pulprirs= pulpri.executeQuery();
		ArrayList<Object> pulpriv=new ArrayList<Object>();
		pulpriv.add("pullPrivate");
		while (pulprirs.next())
		{
			pulpriv.add(pulprirs.getInt(1));
			pulpriv.add(pulprirs.getString(2));
			pulpriv.add(pulprirs.getString(3));
			pulpriv.add(pulprirs.getString(4));
			pulpriv.add(pulprirs.getString(5));
			pulpriv.add(pulprirs.getString(6));
		}
		client.sendToClient(pulpriv);
		
		
	}

}
